import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
import Layout from '@/layout'


// // 解决编程式路由往同一地址跳转时会报错的情况
// const originalPush = VueRouter.prototype.push;
// const originalReplace = VueRouter.prototype.replace;
//
// // push
// VueRouter.prototype.push = function push(location, onResolve, onReject) {
//     if (onResolve || onReject)
//         return originalPush.call(this, location, onResolve, onReject);
//     return originalPush.call(this, location).catch(err => err);
// };
//
// //replace
// VueRouter.prototype.replace = function push(location, onResolve, onReject) {
//     if (onResolve || onReject)
//         return originalReplace.call(this, location, onResolve, onReject);
//     return originalReplace.call(this, location).catch(err => err);
// };



const routes = [
    {
        path: '/redirect',
        component: Layout,
        meta: {authority: [0], id: 20000},
        children: [
            {
                meta: {authority: [100], id: 20000},
                path: '/redirect/:path(.*)',
                component: () => import(/* webpackChunkName: "redirect-index" */ '@/views/redirect/index')
            }
        ]
    },
    {
        path: '/',
        redirect: '/login',
        meta: {authority: [0]},
    }, {
        path: '/login',
        name: 'login',
        meta: {authority: [0]},
        component: () => import(/* webpackChunkName: "login" */ '@/views/login')
    }, {
        path: '/dashboard',
        name: 'dashboard',
        component: Layout,
        redirect: '/dashboard/index',
        meta: {title: '首页', authority: [100], onlyOne: 1, id: 20000, icon: 'el-icon-s-home'},
        children: [{
            path: 'index',
            name: 'index',
            meta: {title: '首页', authority: [100]},
            component: () => import(/* webpackChunkName: "dashboard" */ '@/views/dashboard')
        }]
    },

    // {
    //     path: '/navigation0',
    //     name: 'navigation0',
    //     component: Layout,
    //     redirect: '/navigation0/index',
    //     meta: {title: '运营看板', authority: [100], onlyOne: 1, id: 20000, icon: 'el-icon-s-home'},
    //     children: [{
    //         path: 'index',
    //         name: 'navigation0',
    //         meta: {title: '运营看板', authority: [100]},
    //         component: () => import(/* webpackChunkName: "navigation0" */ '@/views/navigation0')
    //     }]
    // },
    //
    // {
    //     path: '/navigation41',
    //     name: 'navigation41',
    //     component: Layout,
    //     redirect: '/navigation41/index',
    //     meta: {title: '公告管理', authority: [100], onlyOne: 1, id: 20000, icon: 'el-icon-s-home'},
    //     children: [{
    //         path: 'index',
    //         name: 'navigation41',
    //         meta: {title: '公告管理', authority: [100]},
    //         component: () => import(/* webpackChunkName: "navigation41" */ '@/views/navigation0')
    //     }]
    // },
    // {
    //     path: '/navigation30',
    //     name: 'navigation30',
    //     component: Layout,
    //     redirect: '/navigation30/index',
    //     meta: {title: '物资管理', authority: [100], onlyOne: 1, id: 20000, icon: 'el-icon-s-home'},
    //     children: [{
    //         path: 'index',
    //         name: 'navigation30',
    //         meta: {title: '物资管理', authority: [100]},
    //         component: () => import(/* webpackChunkName: "navigation30" */ '@/views/navigation30')
    //     }]
    // },
    //
    // {
    //     path: '/navigation31',
    //     name: 'navigation31',
    //     component: Layout,
    //     redirect: '/navigation31/index',
    //     meta: {title: '财务管理', authority: [100], onlyOne: 1, id: 20000, icon: 'el-icon-s-home'},
    //     children: [{
    //         path: 'index',
    //         name: 'navigation31',
    //         meta: {title: '财务管理', authority: [100]},
    //         component: () => import(/* webpackChunkName: "navigation31" */ '@/views/navigation31')
    //     }]
    // },
    //
    // {
    //     path: '/navigation36',
    //     name: 'navigation36',
    //     component: Layout,
    //     redirect: '/navigation36/index',
    //     meta: {title: '个人中心', authority: [100], onlyOne: 1, id: 20000, icon: 'el-icon-s-home'},
    //     children: [{
    //         path: 'index',
    //         name: 'navigation36',
    //         meta: {title: '审批管理', authority: [100]},
    //         component: () => import(/* webpackChunkName: "navigation36" */ '@/views/navigation36')
    //     }]
    // },
    //
    // {
    //     path: '/navigation37',
    //     name: 'navigation37',
    //     component: Layout,
    //     redirect: '/navigation37/index',
    //     meta: {title: '文档管理', authority: [100], onlyOne: 1, id: 20000, icon: 'el-icon-s-home'},
    //     children: [{
    //         path: 'index',
    //         name: 'navigation37',
    //         meta: {title: '文档管理', authority: [100]},
    //         component: () => import(/* webpackChunkName: "navigation37" */ '@/views/navigation37')
    //     }]
    // },
    //
    // {
    //     path: '/navigation14',
    //     name: 'navigation14',
    //     component: Layout,
    //     redirect: '/navigation14/navigation14',
    //     meta: {title: '招聘管理', authority: [100], id: 20000, icon: 'el-icon-s-cooperation'},
    //     children: [
    //         {
    //             path: 'navigation43',
    //             name: 'navigation43',
    //             meta: {title: '招聘计划', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation43" */ '@/views/navigation43')
    //         },
    //         {
    //             path: 'navigation45',
    //             name: 'navigation45',
    //             meta: {title: '简历管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation45" */ '@/views/navigation45')
    //         },
    //
    //     ]
    // },
    //
    // {
    //     path: '/navigation1',
    //     name: 'navigation1',
    //     component: Layout,
    //     redirect: '/navigation1/navigation2',
    //     meta: {title: '经营战略', authority: [100], id: 20000, icon: 'el-icon-loading'},
    //     children: [
    //         {
    //             path: 'navigation2',
    //             name: 'navigation2',
    //             meta: {title: '历史数据', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation2" */ '@/views/navigation2')
    //         },
    //
    //         {
    //             path: 'navigation3',
    //             name: 'navigation3',
    //             meta: {title: '成本定义', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation3" */ '@/views/navigation3')
    //         },
    //
    //         {
    //             path: 'navigation4',
    //             name: 'navigation4',
    //             meta: {title: '成本管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation4" */ '@/views/navigation4')
    //         },
    //
    //         {
    //             path: 'navigation5',
    //             name: 'navigation5',
    //             meta: {title: '经营可视图', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation5" */ '@/views/navigation5')
    //         },
    //     ]
    // },
    //
    // {
    //     path: '/navigation6',
    //     name: 'navigation6',
    //     component: Layout,
    //     redirect: '/navigation6/navigation7',
    //     meta: {title: '审批管理', authority: [100], id: 20000, icon: 'el-icon-loading'},
    //     children: [
    //         {
    //             path: 'navigation7',
    //             name: 'navigation7',
    //             meta: {title: '审批模板', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation7" */ '@/views/navigation7')
    //         },
    //
    //         {
    //             path: 'navigation8',
    //             name: 'navigation8',
    //             meta: {title: '审批活动', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation8" */ '@/views/navigation8')
    //         },
    //     ]
    // },
    //
    // {
    //     path: '/navigation9',
    //     name: 'navigation9',
    //     component: Layout,
    //     redirect: '/navigation9/navigation10',
    //     meta: {title: '人事管理', authority: [100], id: 20000, icon: 'el-icon-user'},
    //     children: [
    //         {
    //             path: 'navigation10',
    //             name: 'navigation10',
    //             meta: {title: '部门管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation10" */ '@/views/navigation10')
    //         },
    //
    //         {
    //             path: 'navigation11',
    //             name: 'navigation11',
    //             meta: {title: '员工档案', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation11" */ '@/views/navigation11')
    //         },
    //
    //         {
    //             path: 'navigation13',
    //             name: 'navigation13',
    //             meta: {title: '薪酬福利', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation13" */ '@/views/navigation13')
    //         },
    //
    //     ]
    // },
    //
    // {
    //     path: '/navigation18',
    //     name: 'navigation18',
    //     component: Layout,
    //     redirect: '/navigation18/navigation19',
    //     meta: {title: '考勤管理', authority: [100], id: 20000, icon: 'el-icon-loading'},
    //     children: [
    //         {
    //             path: 'navigation19',
    //             name: 'navigation19',
    //             meta: {title: '考勤规则', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation19" */ '@/views/navigation19')
    //         },
    //
    //         {
    //             path: 'navigation20',
    //             name: 'navigation20',
    //             meta: {title: '打卡记录', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation20" */ '@/views/navigation20')
    //         },
    //
    //         {
    //             path: 'navigation21',
    //             name: 'navigation21',
    //             meta: {title: '请假管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation21" */ '@/views/navigation21')
    //         },
    //
    //         {
    //             path: 'navigation22',
    //             name: 'navigation22',
    //             meta: {title: '加班管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation22" */ '@/views/navigation22')
    //         },
    //     ]
    // },
    //
    // {
    //     path: '/navigation23',
    //     name: 'navigation23',
    //     component: Layout,
    //     redirect: '/navigation23/navigation24',
    //     meta: {title: '客户管理', authority: [100], id: 20000, icon: 'el-icon-loading'},
    //     children: [
    //         {
    //             path: 'navigation24',
    //             name: 'navigation24',
    //             meta: {title: '客户信息', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation24" */ '@/views/navigation24')
    //         },
    //
    //         {
    //             path: 'navigation25',
    //             name: 'navigation25',
    //             meta: {title: '商机管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation25" */ '@/views/navigation25')
    //         },
    //     ]
    // },
    //
    // {
    //     path: '/navigation26',
    //     name: 'navigation26',
    //     component: Layout,
    //     redirect: '/navigation26/navigation27',
    //     meta: {title: '项目管理', authority: [100], id: 20000, icon: 'el-icon-loading'},
    //     children: [
    //         {
    //             path: 'navigation27',
    //             name: 'navigation27',
    //             meta: {title: '项目计划', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation27" */ '@/views/navigation27')
    //         },
    //
    //         {
    //             path: 'navigation28',
    //             name: 'navigation28',
    //             meta: {title: '项目列表', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation28" */ '@/views/navigation28')
    //         },
    //
    //         {
    //             path: 'navigation29',
    //             name: 'navigation29',
    //             meta: {title: '任务管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation29" */ '@/views/navigation29')
    //         },
    //     ]
    // },
    //
    // {
    //     path: '/navigation32',
    //     name: 'navigation32',
    //     component: Layout,
    //     redirect: '/navigation32/navigation33',
    //     meta: {title: '产品租赁', authority: [100], id: 20000, icon: 'el-icon-folder'},
    //     children: [
    //         {
    //             path: 'navigation42',
    //             name: 'navigation42',
    //             meta: {title: '产品管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation42" */ '@/views/navigation42')
    //         },
    //
    //         {
    //             path: 'navigation34',
    //             name: 'navigation34',
    //             meta: {title: '租户管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation34" */ '@/views/navigation34')
    //         },
    //
    //         {
    //             path: 'navigation35',
    //             name: 'navigation35',
    //             meta: {title: '租赁管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation35" */ '@/views/navigation35')
    //         },
    //     ]
    // },
    //
    // {
    //     path: '/navigation38',
    //     name: '客户管理',
    //     component: Layout,
    //     redirect: '/navigation38/navigation39',
    //     meta: {title: '系统管理', authority: [100], id: 20000, icon: 'el-icon-monitor'},
    //     children: [
    //         {
    //             path: 'navigation16',
    //             name: 'navigation16',
    //             meta: {title: '用户管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation16" */ '@/views/navigation16')
    //         },
    //
    //         {
    //             path: 'navigation17',
    //             name: 'navigation17',
    //             meta: {title: '角色管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation17" */ '@/views/navigation17')
    //         },
    //
    //         {
    //             path: 'navigation33',
    //             name: 'navigation33',
    //             meta: {title: '资源管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation33" */ '@/views/navigation33')
    //         },
    //
    //         {
    //             path: 'navigation39',
    //             name: '客户管理',
    //             meta: {title: '字典管理', authority: [100], id: 20000},
    //             component: () => import(/* webpackChunkName: "navigation39" */ '@/views/navigation39')
    //         },
    //
    //
    //     ]
    // },
    //
    // {
    //     path: '/systemSettings',
    //     name: 'systemSettings',
    //     component: Layout,
    //     redirect: '/systemSettings/roleSetUp',
    //     meta: {title: '系统设置', authority: [100], id: 20000, icon: 'el-icon-setting'},
    //     children: [{
    //         path: 'roleSetUp',
    //         name: 'roleSetUp',
    //         meta: {title: '角色设置', authority: [100], id: 20000},
    //         component: () => import(/* webpackChunkName: "/systemSettings/roleSetUp" */ '@/views/systemSettings/roleSetUp')
    //     }, {
    //         path: 'accountSettings',
    //         name: 'accountSettings',
    //         meta: {title: '账号设置', authority: [100], id: 20000},
    //         component: () => import(/* webpackChunkName: "/systemSettings/accountSettings" */ '@/views/systemSettings/accountSettings')
    //     }, {
    //         path: 'systemLog',
    //         name: 'systemLog',
    //         meta: {title: '系统日志', authority: [100], id: 20000},
    //         component: () => import(/* webpackChunkName: "/systemSettings/systemLog" */ '@/views/systemSettings/systemLog')
    //     }]
    // },
]
const router = new VueRouter({
    routes
})
export default router
